<template>
  <div class="recommended">
    <div class="recommended-header">
      <div class="search-input-con">
        <SearchInput />
      </div>
      <div class="label-manage-entry">
        <div class="label-manage-entry__icon iconfont icon-shezhi"></div>
        <div class="label-manage-entry__text">标签</div>
      </div>
    </div>
    <div class="recommended-nav">
      <Nav :currentCategoryIndex="1" />
    </div>
    <div class="recommended-item">
      <div class="items"
           v-for="article in data">
        <div :key="article.article_id"
             class="articel_content"
             @click="goto(article.article_id)">
          <div class="auther_name">{{article.auther_name}}</div>
          <!-- <div class="data">{{article.mtime}}</div> -->
          <div class="tag_list">
            <div class="tag">{{article.tag}}</div>
          </div>
          <div class=".content-wrapper">
            <div class=".content-main">
              <div class="title-row">
                <div class="article_title">
                  <span>{{article.title}}</span>
                </div>
              </div>
              <div class="abstract">
                <div class="article_brief">
                  <p>{{ article.brief_content }}</p>
                </div>
              </div>
              <ul class="action-list">
                <li class="item view">
                  <i></i>
                  <span>{{article.view_count}}</span>
                </li>
                <li class="item ">
                  <i></i>
                  <span>{{article.view_count}}</span>
                </li>
                <li class="item ">
                  <i></i>
                  <span>{{article.view_count}}</span>
                </li>
              </ul>
              <img :src="article.cover_image" alt="" class="thumb lazy">
            </div>
            
          
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import SearchInput from '../../../../components/search-input/index.vue'
import Nav from './components/nav/index.vue'
import useRecommendAll from './useRecommendAll.ts'
import { useRouter } from 'vue-router'

export default defineComponent({
  components: {
    SearchInput,
    Nav,
  },
  setup() {
    const router = useRouter()
    let data = ref([])
    const goto = (id) => {
      // console.log(id)
      router.push('/post/' + id)
    }
    useRecommendAll(10).then((res) => {
      for (let v of res) {
        // console.log(v);
        data.value.push(v)
      }
    })
    console.log(data)
    return {
      data,
      goto,
    }
  },
})
</script>

<style scoped lang="less">
.recommended {
  &-header {
    display: flex;
    align-items: center;
    padding: 20 * @unit 50 * @unit;
    background-color: @white;
    .search-input-con {
      flex: 1;
      margin-right: 25 * @unit;
    }
    .label-manage-entry {
      display: flex;
      align-items: center;
      flex-shrink: 0;
      flex-grow: 0;
      color: @secondary-text-color;
      &__icon {
        margin-right: 10 * @unit;
      }
    }
  }
}

.recommended-item {
  background-color: #fff;
  margin-top: .5rem;
}
.item {
  width: 100%;
  cursor: pointer;
}
.articel_content {
  position: relative;
    background: #fff;
    padding: 12px 20px 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.content-wrapper {
    display: flex;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e6eb;
    margin-top: 10px;
    width: 100%;
}
.content-wrapper .content-main {
    flex: 1 1 auto;
}
.title-row {
    display: flex;
    margin-bottom: 8px;
}
.abstract {
  margin-bottom: 10px;
}
.auther_name {
  font-size: 14px;
  font-weight: 200;
  margin-top: 10px;
  margin-bottom: 15px;
}
.data {
  margin: 0 8px;
  line-height: 22px;
  font-size: 13px;
  flex-shrink: 0;
}
.tag_list {
    display: flex;
    align-items: center;
}
.article_title {
  // font-weight: 600;
  // margin-bottom: 10px;
    font-weight: 700;
    font-size: 16px;
    line-height: 24px;
    color: #1d2129;
    width: 100%;
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
}

.article_brief {
  font-size: 14px;
  line-height: 22px;
  margin-bottom: 14px;
}
.action-list .action-list>.item {
  display: flex;
  align-items: center;
}
.action-list>.item {
  
    position: relative;
    margin-right: 20px;
    font-size: 13px;
    line-height: 20px;
    color: #4e5969;
    flex-shrink: 0;
}
// .action-list>.item i {
//     display: block;
//     width: 16px;
//     height: 16px;
//     background-size: 100%;
// }
// i {
//     font-style: italic;
// }
.thumb {
    flex: 0 0 auto;
    width: 120px;
    height: 80px;
    margin-left: 24px;
    background-color: #fff;
    border-radius: 2px;
}
.lazy {
    position: relative;
    -o-object-fit: cover;
    object-fit: cover;
}
</style>